package com.century.sjt.adapter;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
import com.century.sjt.R;
import com.century.sjt.entity.BankCard;
import com.century.sjt.util.SrcUtil;

import java.util.List;
import java.util.Map;

/**
 * Created by 炳基 on 2016/8/5.
 * 国家/地区/语言
 *
 */
public class ItemMoreAdapter extends BaseAdapter {
    private LayoutInflater mLayoutInflater;
    // 映射数据
    private List<Map<String, Object>> dataList;
    private Context context;
    private String mType;
    private int mLayout;
    public ItemMoreAdapter(Context context, List<Map<String, Object>> dataList, String type) {
        mLayoutInflater = LayoutInflater.from(context);
        this.context = context;
        this.dataList = dataList;
        this.mType = type;
    }
    @Override
    public int getCount() {
        return dataList.size();
    }

    @Override
    public Object getItem(int position) {
        Map<String,Object> item=null;
        if(null!=dataList){
            item=dataList.get(position);
        }
        return item;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView==null){
            switch (mType){
                case "language":
                    mLayout = R.layout.choose_language_item;
                    break;
                case "mobile":
                    break;

            }
            convertView = mLayoutInflater.inflate(mLayout,null);
            holder=new ViewHolder();
            holder.mtext= (TextView) convertView.findViewById(R.id.choose_text);
            convertView.setTag(holder);
        }else{
            holder= (ViewHolder) convertView.getTag();
        }

        holder.mtext.setText((String)dataList.get(position).get("name"));
        return convertView;
    }

    private static class ViewHolder {
        private TextView mtext;
    }
}
